﻿


/*
暂定通过工艺卡id和工件类型id来获取页面上的所有内容
 */
var techId = 4
var workCountId = 4
var taskId

/*
首先通过工艺卡id来取
    检测准备中的：
        增感屏        胶片牌号            显影时间
        显影温度        射线源种类        焦点尺寸
        胶片规格        像质计型号        洗片条件
        显影液
    检测工艺参数中的：
                        焦距            分段数
        一次透照长度                    像质计灵敏度
        管电压/源活度        曝光时间
        技术等级                        透照方式
 */

$.ajax({
    url: '/taskPaper',
    type: 'post',
    data: {'requestType': 'initBaseInfo_1', 'tech_id': techId},
    success: function (data, status) {
        if (status == 'success') {
            document.getElementById('zengganping').innerHTML = data.tech_screen
            document.getElementById('jiaopianpaihao').innerHTML = data.tech_filmBrand
            document.getElementById('xianyingshijian').innerHTML = data.tech_devTime
            document.getElementById('xianyingwendu').innerHTML = data.tech_devT
            document.getElementById('shexianyuanzhonglei').innerHTML = data.tech_ray
            document.getElementById('jiaodianchicun').innerHTML = data.tech_focus
            document.getElementById('jiaopianguige').innerHTML = data.tech_filmV
            document.getElementById('xiangzhiji').innerHTML = data.tech_IQIV
            document.getElementById('xipiantiaojian').innerHTML = data.tech_devCondition
            document.getElementById('xianyingye').innerHTML = data.tech_liquor


            document.getElementById('jiaoju').innerHTML = data.tech_focalDis
            document.getElementById('fenduanshu').innerHTML = data.tech_seg
            document.getElementById('touzhaochangdu').innerHTML = data.tech_tranLen
            document.getElementById('xiangzhijilingmindu').innerHTML = data.tech_IQISen
            document.getElementById('guandianya').innerHTML = data.tech_V
            document.getElementById('baoguangshijian').innerHTML = data.tech_time
            document.getElementById('jishudengji').innerHTML = data.tech_level
            document.getElementById('touzhaofangshi').innerHTML = data.tech_tranType

            console.log('initBaseInfo_1 成功')
        }
    },
    error: function (data, status) {
        if (status == 'error') {
        }
    }
});


/*
然后通过工艺卡id来取：
    工件信息中的：部件/管线编号  工件/焊缝编号   部件/管线名称   检测比例    规格   材质     坡口形式   焊接方法     焊接时间   检测方法      合格级别
    同时设置下面检测工艺参数中的：工件规格、检测比例、合格级别
 */

var opertions = []
var opertionNum
$.ajax({
    url: '/taskPaper',
    type: 'post',
    data: {'requestType': 'initBaseInfo_2', 'w_techid': techId},
    async: false,
    success: function (data, status) {
        if (status == 'success') {
            opertionNum = data.length
            for (var i = 0; i < data.length; i++){
                opertions[i] = [data[i].w_pipeNum, data[i].w_weldNum, data[i].w_pipeName, data[i].w_scale, data[i].w_spec,
                    data[i].w_texture, data[i].w_type, data[i].w_weldM, data[i].w_weldTime, data[i].w_test, data[i].w_qua]

            }
            document.getElementById('gongjianguige').innerHTML = data[0].w_spec
            document.getElementById('jiancebili').innerHTML = data[0].w_scale
            document.getElementById('hegejibie').innerHTML = data[0].w_qua
        }
    },
    error: function (data, status) {
        if (status == 'error') {
        }
    }
});

/*
最后通过委托单id来取：
    基本信息中的：
        项目名称        产品名称     检测标准
        检测时机        检测地点

但需要通过工艺卡id拿到委托单id
 */
//通过工艺卡id拿到委托单id
$.ajax({
    url: '/taskPaper',
    type: 'post',
    data: {'requestType': 'getTaskId', 'tech_id': techId},
    async: false,
    success: function (data, status) {
        if (status == 'success') {
            taskId = data.tech_tid
        }
    },
    error: function (data, status) {
        if (status == 'error') {
        }
    }
});
// 获取上面所说的数据
$.ajax({
    url: '/taskPaper',
    type: 'post',
    data: {'requestType': 'initBaseInfo_3', 'task_id': taskId},
    success: function (data, status) {
        if (status == 'success') {
            document.getElementById('xiangmumingcheng').innerHTML = data.task_pname
            document.getElementById('chanpinmingcheng').innerHTML = data.task_product
            document.getElementById('jianceshiji').innerHTML = data.task_state
            document.getElementById('jiancedidian').innerHTML = data.task_addr
            document.getElementById('jiancebiaozhun').innerHTML = data.task_standard

            console.log('initBaseInfo_3 成功')
        }
    },
    error: function (data, status) {
        if (status == 'error') {
        }
    }
});


// //获取： 工件规格    检测比例    合格级别
// $.ajax({
//     url: '/taskPaper',
//     type: 'post',
//     data: {'requestType': 'initBaseInfo_4', 'wc_id': workCountId},
//     success: function (data, status) {
//         if (status == 'success') {
//             document.getElementById('gongjianguige').innerHTML = data.wc_spec
//             document.getElementById('jiancebili').innerHTML = data.wc_scale
//             document.getElementById('hegejibie').innerHTML = data.wc_qua
//
//             console.log('initBaseInfo_4 成功')
//         }
//     },
//     error: function (data, status) {
//         if (status == 'error') {
//         }
//     }
// });


//列数 = 10
var methodCount = 10
var table = document.getElementById("opertionInfos");
var tbody = table.children[1];
var inner = "<td>&nbsp;</td>";
for (var j = 0; j < methodCount; j++) {
    inner += "<td />";
}
for (var j = 0; j < opertionNum; j++) {
    var tr = document.createElement("tr");
    tr.innerHTML = inner;
    tbody.appendChild(tr);
}
//显示数据
for (var i = 0; i < opertionNum; i++) {
    if (opertions[i] !== undefined) {
        for (var j = 0; j < methodCount+1; j++) {
            tbody.children[i].children[j].innerHTML = opertions[i][j];
        }
        var attr = "";
        for (j = 0; j < methodCount+1; j++) {
            attr += j === 0 ? "?" : "&";
            attr += "attr" + j + "=" + opertions[i][j];
        }
    } else {
        tbody.children[i].children[0].innerHTML = "&nbsp;";
        for (j = 1; j < methodCount+ 1; j++) {
            tbody.children[i].children[j].innerHTML = "";
        }
    }
}